﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;

/// <summary>
/// sqlhelper 的摘要说明
/// </summary>
public class sqlhelper
{
    public sqlhelper()
    {
        
    }
    private static string strcon = ConfigurationManager.ConnectionStrings["strcon"].ConnectionString;
    public static SqlConnection conn = new SqlConnection(strcon);

    public static int getsclar(string sql,params SqlParameter [] values)
    {
        SqlCommand cmd = conn.CreateCommand();
        cmd.CommandText = sql;
        return (int)cmd.ExecuteScalar();
    }
    public static int getnonquery(string sql, params SqlParameter[] values)
    {
        SqlCommand cmd = conn.CreateCommand();
        cmd.CommandText = sql;
        return (int)cmd.ExecuteNonQuery();
    }
    public static SqlDataReader sreader(string sql, params SqlParameter[] values)
    {
        SqlCommand cmd = conn.CreateCommand();
        cmd.CommandText = sql;
        SqlDataReader sdr = cmd.ExecuteReader();
        return sdr;
    }
}